import {useRoutes,RouteObject,Navigate} from 'react-router-dom'
import React  from 'react'
import Layout from '../views/layout'
import lazyload from './lazyload'
// 声明一个变量把路由方法return出去
export const router_item:Array<object>=[
    {path:'/',label:"首页",element:<Navigate to="/login" />,key:'/'},
    {path:'/login',label:"登录",
    // element:<Login/>,
    element:lazyload(React.lazy(()=>import('../views/login') )),
    key:'login',
    meta:{title:"登录页",key:"login",unWantedAuth:true}},
    {path:'/resetPas',label:"重置密码",element:lazyload(React.lazy(()=>import('../views/login') )),key:'resetPas',
    meta:{title:"重置密码",key:"resetPas",unWantedAuth:true}},
    {label:"控制台",
    key:"layout",
        path:'/layout',
        element:<Layout/>,
        children:[
            {path:'user',key:'user',label:"用户",element:lazyload(React.lazy(()=>import('../views/user') )),
            children:[
                {path:'user1',key:'user1',label:"用户1",element:lazyload(React.lazy(()=>import('../views/user') ))},
                {path:'home1',key:'home1',label:"首页1",element:lazyload(React.lazy(()=>import('../views/home') ))},
            ]},
            {path:'home',key:'home',label:"首页",element:lazyload(React.lazy(()=>import('../views/home') ))},
        ]
    },
    {path:'/404',label:"404",element:lazyload(React.lazy(()=>import('../views/error/404') )),key:'error',meta:{title:"404",key:"error",unWantedAuth:true}},
    {path:'*',element:<Navigate to="/404" />},
]
const GetRoutes=()=>{
    const routes:RouteObject[]=useRoutes(router_item)
    return routes
}
export default GetRoutes